<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>
<#assign css>
    <link rel="stylesheet" href="/assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker3.css">
    <style>

    </style>
</#assign>
<#assign js>
    <script src="/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="/assets/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"
            charset="UTF-8"></script>
    <script>
        //tableId,queryId,conditionContainer
        //var userTable;
        $(function () {
            var thisType = "${orderSearch.type!}";
            if (thisType) {
                initChildType(thisType);
            }
            //Date picker
            $('#datepicker').datepicker({
                autoclose: true,
                format: "yyyy-mm-dd",
                todayHighlight: true,
                language: "zh-CN"
            });
            $('#datepicker-end').datepicker({
                autoclose: true,
                format: "yyyy-mm-dd",
                todayHighlight: true,
                language: "zh-CN"
            });
            $('#datepicker').unbind("change");
            $('#datepicker').change(function () {
                $('#datepicker-end').datepicker('setStartDate', $("#datepicker").val());
            });
            $('#datepicker-end').unbind("change");
            $('#datepicker-end').change(function () {
                $('#datepicker').datepicker('setEndDate', $("#datepicker-end").val());
            });

            $('input[name="status"]').click(function () {
                $('#form').submit();
            })
        });
    </script>
</#assign>
<@layout title="订单列表" active="partner">
    <!-- Content Header (Page header) -->

    <!-- Main content -->
    <section class="content">
        <!-- Default box -->
        <div class="box box-primary">
            <div class="box-header">
                <form class="form-horizontal form-edit" method="post" action="/order/partnerOrderList/${orderSearch.userId}" id="form">
                    <div class="form-group">
                        <div class="col-sm-2">
                            <div class="input-group date">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                                <input type="text" placeholder="开始日期" name="startDate" class="form-control pull-right"
                                       id="datepicker" value="${(orderSearch.startDate?string('yyyy-MM-dd'))!}">
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="input-group date">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                                <input type="text" placeholder="结束日期" name="endDate" class="form-control pull-right"
                                       id="datepicker-end" value="${(orderSearch.endDate?string('yyyy-MM-dd'))!}">
                            </div>
                        </div>

                        <div class="btn-group">
                            <button type="submit" class="btn btn-primary" data-btn-type="search">查询</button>
                            <button type="button" class="btn btn-default" data-btn-type="reset"
                                    onclick="javascript:$('#form')[0].reset();">重置
                            </button>
                            <a class="btn btn-success" href="/order/partnerOrderExport/${orderSearch.userId}">导出</a>
                        </div>
                    </div>
                    <div class="form-group" id="status_group">
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_1" value="0" class="flat-red" <#if orderSearch.status == 0>checked="checked"</#if>/> <label for="status_1">全部</label>
                        </div>
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_2" value="2" class="flat-red" <#if orderSearch.status == 2>checked="checked"</#if>/> <label for="status_2">待接单</label>
                        </div>
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_3" value="4" class="flat-red" <#if orderSearch.status == 4>checked="checked"</#if>/> <label for="status_3">待取件</label>
                        </div>
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_4" value="5" class="flat-red" <#if orderSearch.status == 5>checked="checked"</#if>/> <label for="status_4">配送中</label>
                        </div>
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_5" value="3" class="flat-red" <#if orderSearch.status == 3>checked="checked"</#if>/> <label for="status_5">服务中</label>
                        </div>
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_6" value="6" class="flat-red" <#if orderSearch.status == 6>checked="checked"</#if>/> <label for="status_6">待评价</label>
                        </div>
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_7" value="7" class="flat-red" <#if orderSearch.status == 7>checked="checked"</#if>/> <label for="status_7">已评价</label>
                        </div>
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_8" value="8" class="flat-red" <#if orderSearch.status == 8>checked="checked"</#if>/> <label for="status_8">已取消</label>
                        </div>
                        <div class="col-sm-1">
                            <input type="radio" name="status" id="status_9" value="1" class="flat-red" <#if orderSearch.status == 1>checked="checked"</#if>/> <label for="status_9">待支付</label>
                        </div>
                    </div>
                </form>

                <@shiro.hasPermission name="system:order:add">
                    <a class="btn btn-sm btn-success" href="/order/add">新增</a>
                </@shiro.hasPermission>
            </div>
            <div class="box-body">
                <table class="table table-striped">
                    <tr>
                        <th>序号</th>
                        <th>分站ID</th>
                        <th>订单号</th>
                        <th>金额</th>
                        <th>订单状态</th>
                        <th>发单时间</th>
                        <th>支付类型</th>
                        <th>操作</th>
                    </tr>
                    <#list pageInfo.list as item>
                        <tr>
                            <td>${item.id!}</td>
                            <td>${item.agentId!}</td>
                            <td>${item.orderNo!}</td>
                            <td>${item.amount!}</td>
                            <td>${convert('ORDER_STATUS',item.status) !}</td>
                            <td>${item.createAt?string('yyyy-MM-dd HH:mm:ss')!}</td>
                            <td>${convert('PAY_TYPE',item.payType) !}</td>
                            <td>
                                <@shiro.hasPermission name="orders:order:detail">
                                    <a class="btn btn-sm btn-success" href="/order/detail/${item.id}"
                                       data-btn-type="detail">详情</a>
                                </@shiro.hasPermission>
                            </td>
                        </tr>
                    </#list>
                </table>
            </div>
            <!-- /.box-body -->
            <div class="box-footer clearfix">
                <@macro.page pageInfo=pageInfo url="/order/partnerOrderList/${orderSearch.userId}?" />
            </div>
        </div>
        <!-- /.box -->

    </section>
    <!-- /.content -->
</@layout>
